package com.halixun.d2app.adapter;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.halixun.d2app.R;
import com.halixun.d2app.adapter.holder.HomeNavigationViewHolder;
import com.halixun.d2app.base.BaseViewHolder;
import com.halixun.d2app.bean.FoodCategoryInfo;

import java.util.List;

/**
 * @ProjectName: D2App
 * @Package: com.halixun.d2app.adapter
 * @ClassName: HomeNavigationAdapter
 * @Description: java类作用描述
 * @Author: hdx
 * @CreateDate: 2019/12/14 10:27
 * @UpdateUser: hdx
 * @UpdateDate: 2019/12/14 10:27
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class HomeNavigationAdapter extends RecyclerView.Adapter<BaseViewHolder<FoodCategoryInfo>> {

    private List<FoodCategoryInfo> infos;

    private HomeNavigationListener mListener;

    public HomeNavigationAdapter(List<FoodCategoryInfo> infos){
        this.infos = infos;
    }

    @NonNull
    @Override
    public BaseViewHolder<FoodCategoryInfo> onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new HomeNavigationViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.home_navigation_item,parent,false),mListener);
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder<FoodCategoryInfo> holder, int position) {
        holder.setLayoutInfo(infos.get(position));
    }

    @Override
    public int getItemCount() {
        return infos.size();
    }

    public void setOnHomeNavigationListener(HomeNavigationListener listener){
        this.mListener = listener;
    }

    public interface HomeNavigationListener{
        void onHomeNavigationListener(int position);
    }

}
